package com.ruoyi.job.task;

import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteStaticsticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("statisticTask")
public class StatisticTask
{
//    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
//    {
//        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
//    }
//
//    public void ryParams(String params)
//    {
//        System.out.println("执行有参方法：" + params);
//    }

    private static final Logger logger = LoggerFactory.getLogger(SecurityScheduleTask.class);

    @Autowired
    private RemoteStaticsticsService staticsticsService;

    public void statisticDayParkingMoney(Integer offset)
    {
        System.out.println("statisticTask 执行无参方法");
        //获取当前日期-1，
        Date date = new Date(System.currentTimeMillis() - offset*1000*60*60* 24);
        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
        //调用接口生成报表
        R r = staticsticsService.genStaticByDate(sp.format(date));
        if(r.getCode() == Constants.SUCCESS){
            logger.info("statistic Day Parking Money computed " + date );
        }

    }

}
